{extend name="base"/}
{block name="resources"}
<link rel="stylesheet" href="SHOP_CSS/cert_index.css">
{/block}
{block name="main"}
<!-- 开店套餐 -->
<div class="store-level-box {notempty name='$shop_apply_info.cert_id'}layui-hide{/notempty}">
    <h2 class="apply-h2-title">选择开店套餐</h2>
    <ul class="store-level">
        {foreach $group_info as $shop_group_key => $shop_group_val}
        <li data-group_id = {$shop_group_val["group_id"]} data-group_fee = {$shop_group_val["group_id"]}>
            <h2 class="group_name">{$shop_group_val["group_name"]}</h2>
            <span class="remark">{$shop_group_val["remark"]}</span>
            <ul class="store-level-sublevel">
                {foreach $shop_group_val["promotion"] as $promotion_key => $promotion_val}
                <li>
                    {if $promotion_val.is_checked == 1}<span class="ns-text-color">√</span>{else/}<span class="ns-red-color">×</span>{/if}
                    <span class="{if $promotion_val.is_checked != 1} is-checked{/if}">{$promotion_val.title}</span>
                </li>
                {/foreach}
            </ul>
            <button class="layui-btn ns-bg-color">￥ {$shop_group_val.fee}/年</button>
        </li>
        {/foreach}
    </ul>
</div>

<div class="cert-box">
    <!-- 类型选择 -->
    <div class="application-type layui-hide layui-form">
        <h2>填写公司认证信息</h2>
        <div class="cert-type">
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required">*</span>申请类型：</label>
                <div class="layui-input-inline ns-len-long">
                    <input type="radio" name="cert_type" lay-filter="application_type" value="2" title="公司" checked>
                    <input type="radio" name="cert_type" lay-filter="application_type" value="1" title="个人">
                </div>
            </div>
        </div>
    </div>
    <!-- 公司认证信息 -->
    <div class="layui-hide layui-form company-authentication-info" lay-filter="update_address">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>公司名称：</label>
            <div class="layui-input-inline">
                <input name="company_name" type="text" value="{$shop_apply_info.company_name}" placeholder="请输入公司名称" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>联系地址：</label>
            <div class="layui-input-inline area-select ns-len-short">
                <select name="province_id" lay-filter="province_id" lay-verify="province_id">
                    <option value="">请选择省份</option>
                    {foreach $province_list as $k => $v}
                    <option value="{$v.id}">{$v.name}</option>
                    {/foreach}
                </select>
            </div>

            <div class="layui-input-inline area-select ns-len-short">
                <select name="city_id" lay-filter="city_id" lay-verify="city_id">
                    <option value="">请选择城市</option>
                </select>
            </div>

            <div class="layui-input-inline area-select ns-len-short">
                <select name="district_id" lay-filter="district_id" lay-verify="district_id">
                    <option value="">请选择区/县</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>公司地址：</label>
            <div class="layui-input-inline">
                <input name="company_address" type="text" value="{$shop_apply_info.company_address}" placeholder="请输入详细地址" maxlength="10" autocomplete="off" lay-verify="address" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>统一社会信用码：</label>
            <div class="layui-input-inline">
                <input name="business_licence_number" type="text" value="{$shop_apply_info.business_licence_number}" placeholder="请输入统一社会信用码" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>营业执照电子版：</label>
            <div class="layui-input-inline img-upload">
                <input type="hidden" class="layui-input" lay-verify="required" name="business_licence_number_electronic" value="{$shop_apply_info.business_licence_number_electronic}" />
                <div class="upload-img-block icon" data-upload data-id="businessLicense" data-name="business_licence_number_electronic">
                    <div class="upload-img-box" id="businessLicense">
                        {empty name="$shop_apply_info.business_licence_number_electronic"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.business_licence_number_electronic)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">法定经营范围：</label>
            <div class="layui-input-inline">
                <textarea name="business_sphere" type="text" placeholder="请输入法定经营范围" class="layui-textarea ns-len-long">{$shop_apply_info.business_sphere}</textarea>
            </div>
        </div>

        <!-- <div class="layui-form-item">
            <label class="layui-form-label">纳税人识别号：</label>
            <div class="layui-input-inline">
                <input name="taxpayer_id" value="{$shop_apply_info.taxpayer_id}" type="text" placeholder="请输入识别号" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">税务登记证号：</label>
            <div class="layui-input-inline">
                <input name="tax_registration_certificate" value="{$shop_apply_info.tax_registration_certificate}" type="text" placeholder="请输入税务登记证号" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable">税务登记证电子版：</label>
            <div class="layui-input-block img-upload">
                <input type="hidden" class="layui-input" name="tax_registration_certificate_electronic" value="{$shop_apply_info.tax_registration_certificate_electronic}"/>
                <div class="upload-img-block" data-upload data-id="taxation" data-name="tax_registration_certificate_electronic">
                    <div class="upload-img-box" id="taxation">
                        {empty name="$shop_apply_info.contacts_card_electronic_2"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.tax_registration_certificate_electronic)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
            <div class="ns-word-aux">注意：若公司三证合一，请上传营业执照。</div>
        </div> -->

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>法人姓名：</label>
            <div class="layui-input-inline">
                <input name="contacts_name" type="text" value="{$shop_apply_info.contacts_name}" placeholder="请输入法人姓名" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>法人手机：</label>
            <div class="layui-input-inline">
                <input name="contacts_mobile" type="number" value="{$shop_apply_info.contacts_mobile}" placeholder="请输入手机号" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>法人身份证：</label>
            <div class="layui-input-inline">
                <input name="contacts_card_no" type="text" value="{$shop_apply_info.contacts_card_no}" placeholder="请输入身份证号" lay-verify="required|card" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>法人身份证正面：</label>
            <div class="layui-input-inline img-upload">
                <input type="hidden" class="layui-input" lay-verify="required" name="contacts_card_electronic_2" value="{$shop_apply_info.contacts_card_electronic_2}"/>
                <div class="upload-img-block icon" data-upload data-id="companyPositiveContactsID" data-name="contacts_card_electronic_2">
                    <div class="upload-img-box" id="companyPositiveContactsID">
                        {empty name="$shop_apply_info.contacts_card_electronic_2"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.contacts_card_electronic_3)}" alt="">
                        <img src="{:img($shop_apply_info.contacts_card_electronic_2)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>法人身份证反面：</label>
            <div class="layui-input-inline img-upload">
                <input type="hidden" class="layui-input" lay-verify="required" name="contacts_card_electronic_3" value="{$shop_apply_info.contacts_card_electronic_3}" />
                <div class="upload-img-block icon" data-upload data-id="companyBackContactsID" data-name="contacts_card_electronic_3">
                    <div class="upload-img-box" id="companyBackContactsID">
                        {empty name="$shop_apply_info.contacts_card_electronic_3"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.contacts_card_electronic_3)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>

        <div class="apply-btn-box">
            <button class="ns-bg-color layui-btn authentication-info-step">上一步</button>
            <button class="ns-bg-color layui-btn authentication-info-lower" lay-submit lay-filter="authentication_info">下一步</button>
        </div>

    </div>

    <!-- 个人认证信息 -->
    <div class="personal-authentication-info layui-hide layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>联系人姓名：</label>
            <div class="layui-input-inline">
                <input name="contacts_name" type="text" value="{$shop_apply_info.contacts_name}" placeholder="请输入联系人姓名" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>联系人手机：</label>
            <div class="layui-input-inline">
                <input name="contacts_mobile" type="number" value="{$shop_apply_info.contacts_mobile}" placeholder="请输入联系人手机号" lay-verify="required|phone" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>身份证号：</label>
            <div class="layui-input-inline">
                <input name="contacts_card_no" type="text" value="{$shop_apply_info.contacts_card_no}" placeholder="请输入身份证号" lay-verify="required|card" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>身份证正面：</label>
            <div class="layui-input-inline img-upload">
                <input type="hidden" class="layui-input" lay-verify="required" name="contacts_card_electronic_2" value="{$shop_apply_info.contacts_card_electronic_2}"/>
                <div class="upload-img-block icon" data-upload data-id="positiveContactsID" data-name="contacts_card_electronic_2">
                    <div class="upload-img-box" id="positiveContactsID">
                        {empty name="$shop_apply_info.contacts_card_electronic_2"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.contacts_card_electronic_2)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>身份证反面：</label>
            <div class="layui-input-inline img-upload" data-upload data-id="backContactsID" data-name="contacts_card_electronic_3">
                <input type="hidden" class="layui-input" lay-verify="required" name="contacts_card_electronic_3" value="{$shop_apply_info.contacts_card_electronic_3}"/>
                <div class="upload-img-block icon">
                    <div class="upload-img-box" id="backContactsID">
                        {empty name="$shop_apply_info.contacts_card_electronic_3"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.contacts_card_electronic_3)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>
        <div class="apply-btn-box">
            <button class="ns-bg-color layui-btn authentication-info-step">上一步</button>
            <button class="ns-bg-color layui-btn authentication-info-lower" lay-submit lay-filter="authentication_info">下一步</button>
        </div>
    </div>

    <!-- 银行结算信息 -->
    <div class="application-info-bank layui-hide layui-form" >
        <h2 class="apply-h2-title">填写银行结算信息</h2>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>银行开户名：</label>
            <div class="layui-input-inline">
                <input name="bank_account_name" value="{$shop_apply_info.bank_account_name}" type="text" placeholder="请输入银行开户名" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>开户银行账号：</label>
            <div class="layui-input-inline">
                <input name="bank_account_number" value="{$shop_apply_info.bank_account_number}" type="number" placeholder="请输入开户银行账号" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>开户银行支行名称：</label>
            <div class="layui-input-inline">
                <input name="bank_name" value="{$shop_apply_info.bank_name}" type="text" placeholder="请输入开户银行支行名称" lay-verify="required" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开户银行所在地：</label>
            <div class="layui-input-inline">
                <input name="bank_address" value="{$shop_apply_info.bank_address}" type="text" placeholder="请输入开户银行所在地" class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">支行联行号：</label>
            <div class="layui-input-inline">
                <input name="bank_code" value="{$shop_apply_info.bank_code}" type="number" placeholder="请输入支行联行号"  class="layui-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">结算类型：</label>
            <div class="layui-input-inline">
                {if in_array("bank", $support_transfer_type)}
                <input type="radio" name="bank_type" lay-filter="bankType" value="1" title="银行卡" checked>
                {/if}
                {if in_array("alipay", $support_transfer_type)}
                <input type="radio" name="bank_type" lay-filter="bankType" value="2" title="支付宝">
                {/if}
                {if in_array("wechatpay", $support_transfer_type)}
                <input type="radio" name="bank_type" lay-filter="bankType" value="3" title="微信">
                {/if}
            </div>
        </div>
        <div class="ns-bank-type-1 layui-hide">
            <div class="layui-form-item">
                <label class="layui-form-label type_1_settlement_bank_account_name"><span class="required">*</span>用户真实姓名：</label>
                <div class="layui-input-inline">
                    <input name="zifu_settlement_bank_account_name" value="{$shop_apply_info.settlement_bank_account_name}" type="text" placeholder="请输入用户真实姓名" class="layui-input ns-len-long">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label type_1_settlement_bank_account_number"><span class="required">*</span>支付宝账号：</label>
                <div class="layui-input-inline">
                    <input name="zifu_settlement_bank_account_number" value="{$shop_apply_info.settlement_bank_account_number}" type="number" placeholder="请输入支付宝账号" class="layui-input ns-len-long">
                </div>
            </div>
        </div>
        <div class="ns-bank-type-2">
            <div class="layui-form-item">
                <label class="layui-form-label type_2_settlement_bank_account_name"><span class="required">*</span>结算开户名：</label>
                <div class="layui-input-inline">
                    <input name="settlement_bank_account_name" type="text" value="{$shop_apply_info.settlement_bank_account_name}" placeholder="请输入结算开户名" lay-verify="required" class="layui-input ns-len-long">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label type_2_settlement_bank_account_number"><span class="required">*</span>结算银行账号：</label>
                <div class="layui-input-inline">
                    <input name="settlement_bank_account_number" value="{$shop_apply_info.settlement_bank_account_number}" type="number" placeholder="请输入结算银行账号" lay-verify="required" class="layui-input ns-len-long">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label type_2_settlement_bank_name"><span class="required">*</span>结算开户银行支行名称：</label>
                <div class="layui-input-inline">
                    <input name="settlement_bank_name" type="text" value="{$shop_apply_info.settlement_bank_name}" placeholder="请输入结算开户银行支行名称" lay-verify="required" class="layui-input ns-len-long">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label type_2_settlement_bank_address"><span class="required">*</span>结算开户银行所在地：</label>
                <div class="layui-input-inline">
                    <input name="settlement_bank_address" type="text" value="{$shop_apply_info.settlement_bank_address}" placeholder="请输入结算开户银行所在地" lay-verify="required" class="layui-input ns-len-long">
                </div>
            </div>
        </div>
        <div class="ns-bank-type-3 layui-hide">
            <div class="layui-form-item">
                <label class="layui-form-label type_3_settlement_bank_account_name"><span class="required">*</span>微信绑定：</label>
                <div class="layui-input-block shop-bind">
                    <div class="ns-img-box">
                        <image layer-src src="{:addon_url('shop/apply/shopBindQrcode')}"/>
                        <div class="img-load layui-hide">点击重新加载</div>
                    </div>
                </div>
                <div class="ns-word-aux">请扫描二维码与微信绑定</div>
            </div>

            <div class="layui-form-item layui-hide weixin-nickname">
                <label class="layui-form-label">微信昵称：</label>
                <div class="layui-input-inline">
                    <input type="text" disabled name="weixin_settlement_bank_address" class="layui-input ns-dis-input ns-len-long" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label type_3_settlement_bank_account_name"><span class="required">*</span>用户真实姓名：</label>
                <div class="layui-input-inline">
                    <input name="weixin_settlement_bank_account_name" value="{$shop_apply_info.settlement_bank_account_name}" type="text" placeholder="请输入用户真实姓名" class="layui-input ns-len-long">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label type_3_settlement_bank_account_number"><span class="required">*</span>微信账号：</label>
                <div class="layui-input-inline">
                    <input name="weixin_settlement_bank_name" value="{$shop_apply_info.settlement_bank_account_number}" type="text" placeholder="请输入微信账号" class="layui-input ns-len-long">
                </div>
            </div>
            <!-- 微信openid -->
            <input name="weixin_settlement_bank_account_number" value="" type="hidden" class="layui-input">
        </div>
        <div class="apply-btn-box">
            <button class="ns-bg-color layui-btn application-info-bank-step">上一步</button>
            <button class="ns-bg-color layui-btn application-info-bank-lower" lay-submit lay-filter="application_info_bank">下一步</button>
        </div>
    </div>

    <!-- 店铺信息 -->
    <div class="application-info layui-hide layui-form" >
        <h2 class="apply-h2-title">填写店铺信息</h2>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>店铺名称：</label>
            <div class="layui-input-block">
                <input name="shop_name" disabled value="{$shop.site_name}" type="text" placeholder="请输入店铺名称" maxlength="10" lay-verify="required" class="layui-input ns-dis-input ns-len-long">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>开店套餐：</label>
            <div class="layui-input-inline">
                <input type="text" disabled class="layui-input ns-dis-input ns-len-long" name="group_name" value="{$shop_apply_info.shop_name}">
            </div>
        </div>
        <!-- 开店套餐id隐藏域 -->
        <input type="hidden" class="layui-input" name="group_id">

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>主营行业：</label>
            <div class="layui-input-inline">
                <input type="text" disabled class="layui-input ns-dis-input ns-len-long" name="category_name" value="{$shop.category_name}">
            </div>
        </div>
        <!-- 主营行业id隐藏域 -->
        <input type="hidden" class="layui-input" name="category_id" value="{$shop.category_id}">


        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>入驻时长：</label>
            <div class="layui-input-inline">
                <select name="apply_year" lay-verify="required" lay-search="" lay-filter="apply_year">
                    <option value="">请选择入驻时长</option>
                    {for start="1" end="5"}
                    {notempty name='$shop_apply_info.apply_year'}
                    <option value="{$i}" {if $i == $shop_apply_info.apply_year} selected{/if}>{$i}</option>
                    {else/}
                    <option value="{$i}" {if $i == 1} selected{/if}>{$i}</option>
                    {/notempty}
                    {/for}
                </select>
            </div>
            <div class="layui-word-aux">年</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>保证金：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red cash-deposit"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>服务费：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red service">{$shop_apply_info['paying_apply']} 元</p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>总计：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red store-ccharges">{empty name="$shop_apply_info.paying_amount"} <span></span>{else/}{$shop_apply_info.paying_amount}{/empty} 元</p>
            </div>
            <div class="ns-word-aux">说明：店铺费用 = 服务费 * 入驻年限 + 保证金</div>
        </div>
        <input name="site_id" value="{$shop['site_id']}" type="hidden" class="layui-input">

        <div class="apply-btn-box">
            <button class="ns-bg-color layui-btn application-info-step">上一步</button>
            <button class="ns-bg-color layui-btn application-info-lower" lay-submit lay-filter="application_info">提交，审核资质信息</button>
        </div>
    </div>

    {notempty name="$shop_apply_info['cert_id']"}
    <!-- 审核页面 -->
    <div class="audit-status">
        {if condition="$shop_apply_info['apply_state'] == 3"}
        <h2 class="apply-h2-title">认证成功</h2>
        <div class="shop-succeey">
            <img src="SHOP_IMG/apply/apply_succeed.png" alt="">
            <p>恭喜您认证成功，快进行体验吧！</p>
        </div>
        {else/}
        <h2 class="apply-h2-title">提交平台审核</h2>
        <div class="status">
            {if condition="$shop_apply_info['apply_state'] == 1"}
            <div class="status-pic">
                <img src="SHOP_IMG/apply/under_review.png" alt="">
            </div>
            <span>信息审核中，请稍等 ~</span>
            {elseif condition="$shop_apply_info['apply_state'] == 2 && $shop_apply_info['paying_money_certificate'] == null"}
            <div class="status-pic">
                <img src="SHOP_IMG/apply/in_audit.png" alt="">
            </div>
            <button class="ns-bg-color layui-btn audit-success">审核通过，填写支付凭证</button>
            {elseif condition="$shop_apply_info['apply_state'] == 2"}
            <div class="status-pic">
                <img src="SHOP_IMG/apply/under_review.png" alt="">
            </div>
            <span>支付凭证审核中，请稍等 ~</span>
            {elseif condition="$shop_apply_info['apply_state'] == -1"}
            <div class="status-pic">
                <img src="SHOP_IMG/apply/audit_failure.png" alt="">
            </div>
            <span>审核失败，<span class="error-reason"><a href="#" class="ns-red-color">点击此处查看</a>失败原因</span></span>
            <div class="apply-btn-box">
                <button class="ns-bg-color layui-btn rewrite">重新填写</button>
            </div>
            {elseif condition="$shop_apply_info['apply_state'] == -2"}
            <div class="status-pic">
                <img src="SHOP_IMG/apply/audit_failure.png" alt="">
            </div>
            <span>财务审核失败，<span class="error-reason"><a href="#" class="ns-red-color">点击此处查看</a>失败原因</span></span>
            <div class="apply-btn-box">
                <button class="ns-bg-color layui-btn resubmit">重新提交</button>
            </div>
            {/if}
        </div>
        {/if}
    </div>
    {/notempty}

    <!-- 提交支付凭证 -->
    <div class="payment-voucher layui-hide layui-form">
        <h2 class="apply-h2-title">填写支付信息</h2>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>店铺名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="shop_name" disabled class="layui-input ns-dis-input ns-len-long" value="{$shop.site_name}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>开店套餐：</label>
            <div class="layui-input-inline">
                <input type="text" disabled class="layui-input ns-dis-input ns-len-long" name="group_name" value="{$shop_apply_info['group_name']}">
            </div>
        </div>
        <!-- 开店套餐id隐藏域 -->
        <input type="hidden" class="layui-input" name="group_id" value="{$shop_apply_info['group_id']}">

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>主营行业：</label>
            <div class="layui-input-inline">
                <input type="text" disabled class="layui-input ns-dis-input ns-len-long" name="category_name" value="{$shop.category_name}">
            </div>
        </div>
        <!-- 主营行业id隐藏域 -->
        <input type="hidden" class="layui-input" name="category_id" value="{$shop.category_id}">


        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>入驻时长：</label>
            <div class="layui-input-inline">
                <input type="text" disabled class="layui-input ns-dis-input ns-len-long" name="apply_year" value="{$shop_apply_info.apply_year}">
            </div>
            <div class="layui-word-aux">年</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>保证金：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red payment-cash-deposit">{$shop_apply_info['paying_deposit']} 元</p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>服务费：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red payment-service">{$shop_apply_info['paying_apply']} 元</p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>总计：</label>
            <div class="layui-input-block">
                <p class="ns-input-text color-red payment-store-ccharges">{$shop_apply_info['paying_amount']} 元</p>
            </div>
            <div class="ns-word-aux">
                说明： 店铺费用 = 服务费 * 入驻年限 + 保证金；
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label img-upload-lable"><span class="required">*</span>付款凭证：</label>
            <div class="layui-input-inline img-upload">
                <input type="hidden" class="layui-input" name="paying_money_certificate" value="{$shop_apply_info.paying_money_certificate}"  lay-verify="required"/>
                <div class="upload-img-block icon"  data-upload data-id="voucher" data-name="paying_money_certificate">
                    <div class="upload-img-box" id="voucher">
                        {empty name="$shop_apply_info.paying_money_certificate"}
                        <div class="ns-upload-default">
                            <img src="SHOP_IMG/upload_img.png" />
                            <p>点击上传</p>
                        </div>
                        {else/}
                        <img src="{:img($shop_apply_info.paying_money_certificate)}" alt="">
                        {/empty}
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">付款凭证说明：</label>
            <div class="layui-input-inline">
                <textarea name="paying_money_certificate_explain" class="layui-textarea ns-len-long" placeholder="请输入付款凭证说明">{$shop_apply_info['paying_money_certificate_explain']}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">收款账户信息：</label>
            <div class="layui-input-block">
                <!-- 结算信息 -->
                <table class="layui-table">
                    <colgroup>
                        <col width="25%">
                        <col width="25%">
                        <col width="25%">
                        <col width="25%">
                    </colgroup>
                    <tbody>
                    <tr>
                        <td align="right">银行开户名：</td>
                        <td>{$receivable_config.value.bank_account_name}</td>
                        <td align="right">银行账户：</td>
                        <td>{$receivable_config.value.bank_account_no}</td>
                    </tr>
                    <tr>
                        <td align="right">开户名称：</td>
                        <td>{$receivable_config.value.bank_name}</td>
                        <td align="right">开户所在地：</td>
                        <td>{$receivable_config.value.bank_address}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="apply-btn-box">
            <button class="ns-bg-color layui-btn" lay-submit lay-filter="payment-voucher-complete">点击提交</button>
        </div>

    </div>

</div>
{/block}
{block name="script"}
<script type="text/javascript" src="SHOP_JS/address.js"></script>
<script>
    var form,upload,
        groupId,//开店套餐
        groupFee, //店铺保证金
        groupName,//开店套餐名称
        agreementConsent = false,
        cert_type = 2,
        authentication_info = "",
        application_info_bank = "",
        quicklyOpenShop = true,
        typePayment = 1,
        form_data = "";

    /* 资质审核 - 计算缴费金额 */
    function paymentAmount() {
        var categoryId = "{$shop['category_id']}",
            applyYear = $(".application-info select[name=apply_year] option:selected").val();
        if (categoryId && groupId && applyYear) {
            $.ajax({
                url: ns.url("shop/apply/getApplyMoney"),
                data: {
                    "apply_year": applyYear,
                    "category_id": categoryId,
                    "group_id": groupId
                },
                dataType: 'JSON',
                type: 'POST',
                success: function (data) {
                    console.log(data);
                    $(".cash-deposit").text(data.code.paying_deposit + "元");
                    $(".store-ccharges").text(data.code.paying_amount + ' 元');
                    $(".service").text(data.code.paying_apply + "元");
                }
            })
        }
    };


    /**
     * 开店套餐
     */
    $("body").on("click",".store-level button",function () {

        //获取开店套餐id和名称
        groupId = $(this).parent().attr("data-group_id");
        groupFee = $(this).parent().attr("data-group_fee");
        groupName = $(this).parent().find(".group_name").text();

        $("input[name='group_name']").val(groupName);
        $("input[name='group_id']").val(groupId);
        $(".audit-success").val(groupFee + "元");


        paymentAmount();

        $(".store-level-box").addClass("layui-hide");
        $(".application-type").removeClass("layui-hide");
        !cert_type || cert_type == 2 ? $(".company-authentication-info").removeClass("layui-hide") : $(".personal-authentication-info").removeClass("layui-hide");
    });



    $(function () {
		layui.use(['form','upload'],function () {
			var form = layui.form,
               upload = layui.upload;
			form.render();

            /**
             * 申请类型
             * */
            form.on('radio(application_type)', function(data){
                cert_type = data.value;

                //公司/个人资质信息显示
                if(cert_type == 2){
                    $(".application-type h2").text("填写公司认证信息");
                    $(".company-authentication-info").removeClass("layui-hide");
                    $(".personal-authentication-info").addClass("layui-hide");
                }else if(cert_type == 1){
                    $(".application-type h2").text("填写个人认证信息");
                    $(".company-authentication-info").addClass("layui-hide");
                    $(".personal-authentication-info").removeClass("layui-hide");
                }

            });

           /**
            * 填写个人/公司资质信息
            * */
           //上一步
           $("body").on("click", ".authentication-info-step", function () {

               //将公司/个人资质信息隐藏
               $(".company-authentication-info").addClass("layui-hide");
               $(".personal-authentication-info").addClass("layui-hide");
               //申请类型隐藏
               $(".application-type").addClass("layui-hide");

               $(".store-level-box").removeClass("layui-hide");


           });

           //下一步
           form.on('submit(authentication_info)', function (data) {
               authentication_info = data.field;

               //银行结算信息显示
               $(".application-info-bank").removeClass("layui-hide");

               //申请类型隐藏
               $(".application-type").addClass("layui-hide");

               //个人/公司资质信息隐藏
               if(parseInt(cert_type) == 2){
                   $(".company-authentication-info").addClass("layui-hide");
               } else {
                   $(".personal-authentication-info").addClass("layui-hide");
               }
           });

           /**
            * 银行结算
            * */
           // 上一步
           $("body").on("click", ".application-info-bank-step", function () {
               //结算信息隐藏
               $(".application-info-bank").addClass("layui-hide");

               //申请类型显示
               $(".application-type").removeClass("layui-hide");
               //个人/公司资质信显示
               cert_type == 2 ? $(".company-authentication-info").removeClass("layui-hide") : $(".personal-authentication-info").removeClass("layui-hide");
           });

           //下一步
           form.on('submit(application_info_bank)', function (data) {
               if (typePayment == 2) {
                   data.field.settlement_bank_account_name = data.field.zifu_settlement_bank_account_name;
                   data.field.settlement_bank_account_number = data.field.zifu_settlement_bank_account_number;
               }

               if (typePayment == 3){
                   if (!data.field.weixin_settlement_bank_account_number){
                       layer.msg("请先与微信进行绑定");
                       return false;
                   }
                   data.field.settlement_bank_account_name = data.field.weixin_settlement_bank_account_name; //用户真实姓名
                   data.field.settlement_bank_account_number = data.field.weixin_settlement_bank_account_number; //openid
                   data.field.settlement_bank_address = data.field.weixin_settlement_bank_address; //微信昵称
                   data.field.settlement_bank_name = data.field.weixin_settlement_bank_name; // 微信账号
               }

               application_info_bank = data.field;
               //银行结算信息隐藏
               $(".application-info-bank").addClass("layui-hide");

               //店铺信息显示
               $(".application-info").removeClass("layui-hide");
           });


            //支付类型 显示隐藏
            form.on('radio(bankType)', function(data){
                typePayment = data.value;

                //银行卡
                if(data.value == 1){
                    $(".ns-bank-type-1").addClass("layui-hide");
                    $(".ns-bank-type-3").addClass("layui-hide");
                    $(".ns-bank-type-2").removeClass("layui-hide");
                    $(".type_1_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_1_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_3_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_3_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_account_name").next().find(".layui-input").attr("lay-verify","required");
                    $(".type_2_settlement_bank_account_number").next().find(".layui-input").attr("lay-verify","required");
                    $(".type_2_settlement_bank_name").next().find(".layui-input").attr("lay-verify","required");
                    $(".type_2_settlement_bank_address").next().find(".layui-input").attr("lay-verify","required");
                }
                //支付宝
                if(data.value == 2){
                    $(".ns-bank-type-1").removeClass("layui-hide");
                    $(".ns-bank-type-2").addClass("layui-hide");
                    $(".ns-bank-type-3").addClass("layui-hide");
                    $(".type_2_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_address").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_3_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_3_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_1_settlement_bank_account_name").next().find(".layui-input").attr("lay-verify","required");
                    $(".type_1_settlement_bank_account_number").next().find(".layui-input").attr("lay-verify","required");
                }
                //微信
                if(data.value == 3) {
                    $(".ns-bank-type-1").addClass("layui-hide");
                    $(".ns-bank-type-2").addClass("layui-hide");
                    $(".ns-bank-type-3").removeClass("layui-hide");
                    $(".type_2_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_2_settlement_bank_address").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_1_settlement_bank_account_name").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_1_settlement_bank_account_number").next().find(".layui-input").removeAttr("lay-verify");
                    $(".type_3_settlement_bank_account_name").next().find(".layui-input").attr("lay-verify", "required");
                    $(".type_3_settlement_bank_account_number").next().find(".layui-input").attr("lay-verify", "required");


                    var intervalId;
                    shopBind();

                    function shopBind() {
                        intervalId = window.setInterval(
                            function () {
                                $.ajax({
                                    async: 'false',
                                    type: 'POST',
                                    dataType: 'JSON',
                                    url: ns.url("shop/apply//checkShopBind"),
                                    success: function (res) {

                                        if (res.code == -10001 && res.data.is_expire == 1){
                                            $(".ns-bank-type-3 .img-load").removeClass("layui-hide");
                                            clearInterval(intervalId);
                                            return false;
                                        }

                                        if (res.code >= 0){
                                            $(".ns-bank-type-3 .img-load").removeClass("layui-hide");
                                            $(".ns-bank-type-3 .img-load").html('恭喜您绑定成功！<p class="ns-text-color">重新绑定</p>');
                                            $("input[name='weixin_settlement_bank_account_number']").val(res.data.openid)
                                            $(".weixin-nickname input").val(res.data.userinfo.nickName);
                                            $(".weixin-nickname").attr("data-state", res.code);
                                            $(".weixin-nickname").removeClass("layui-hide");
                                            clearInterval(intervalId);
                                            return false;
                                        }
                                    }
                                });
                            }, 500
                        );
                    }

                    $('body').on("click",".ns-bank-type-3 .img-load",function () {
                        if(parseInt($(".weixin-nickname").attr("data-state")) >= 0){
                            $(".weixin-nickname").addClass("layui-hide");
                        }
                        $(".ns-bank-type-3 img").attr('src',"{:addon_url('shop/apply/shopBindQrcode')}?time="+ Math.random());
                        $(".ns-bank-type-3 .img-load").addClass("layui-hide")
                        shopBind();
                    });
                }
            });


           /**
            * 店铺信息
            * */
           // 上一步
           $("body").on("click", ".application-info-step", function () {
               //银行结算信息显示
               $(".application-info-bank").removeClass("layui-hide");

               //店铺信息隐藏
               $(".application-info").addClass("layui-hide");

               //子流程
               $(".submit-platform dd:nth-child(4)").addClass("apply-side-selected ns-bg-color");
               $(".submit-platform dd:nth-child(5)").removeClass("apply-side-selected ns-bg-color");
           });

           form.on('select(apply_year)', function (data) {
               paymentAmount();
           });

           // 最后保存信息
           form.on('submit(application_info)', function (data) {

               //获取地址
               var provinceId = $("select[name=province_id] option:selected").text(),
                   cityId = $("select[name=city_id] option:selected").text(),
                   districtId = $("select[name=district_id] option:selected").text(),
                   companyAddress = $("input[name=company_address]").val();

               data.field.company_full_address = provinceId + cityId + districtId + companyAddress;

               data.field.cert_type = cert_type;
               form_data = $.extend(authentication_info, application_info_bank, data.field);

               $.ajax({
                   url: ns.url("shop/apply/apply"),
                   dataType: 'JSON',
                   type: 'POST',
                   data: form_data,
                   success: function (data) {
                       if (data.code == 0) {
                           //店铺信息隐藏
                           $(".application-info").addClass("layui-hide");

                           location.reload();
                       }
                   }
               })
           });

           /* 审核失败 */
           $("body").on("click", ".rewrite", function () {
               var type = "{$shop_apply_info.cert_type}";

               if (parseInt(type) == 2) {

                   var province_id = "{$shop_apply_info.company_province_id}",
                       city_id = "{$shop_apply_info.company_city_id}",
                       district_id = "{$shop_apply_info.company_district_id}",
                       initdata = {province_id, city_id, district_id};

                   initAddress(initdata, "update_address");
               }

               $(".audit-status").addClass("layui-hide");
               $(".store-level-box").removeClass("layui-hide");
           });

           /* 财务审核失败 */
           $("body").on("click", ".resubmit", function () {
               $(".audit-status").addClass("layui-hide");
               $(".payment-voucher").removeClass("layui-hide");
           });

           /* 审核成功过 */
           $("body").on("click", ".audit-success", function () {
               $(".audit-status").addClass("layui-hide");
               $(".payment-voucher").removeClass("layui-hide");
           });

           //解析地址
           getAdder(1, 140100);

           function getAdder(level, pid) {
               $.ajax({
                   type: "POST",
                   dataType: 'JSON',
                   url: ns.url("shop/address/getAreaList"),
                   data: {level, pid},
                   async: false,
                   success: function (res) {
                   }
               });
           }


           /* 支付凭证 */
           form.on('submit(payment-voucher-complete)', function (data) {
               $.ajax({
                   url: ns.url("shop/apply/editApply"),
                   dataType: 'JSON',
                   type: 'POST',
                   data: data.field,
                   success: function (data) {
                       if (data.code == 0) {
                           location.reload()
                       }
                   }
               })
           });


           form.on('select(payment_apply_year)', function (data) {
               paymentVoucher();
           });

           paymentVoucher();

           /* 支付凭证 - 缴费金额 */
           function paymentVoucher() {
               var categoryId = "{$shop['category_id']}",
                   groupId = "{$shop_apply_info['group_id']}",
                   applyYear = $(".payment-voucher select[name=apply_year] option:selected").val();

               if (categoryId && groupId && applyYear) {
                   $.ajax({
                       url: ns.url("shop/apply/getApplyMoney"),
                       data: {
                           "apply_year": applyYear,
                           "category_id": categoryId,
                           "group_id": groupId
                       },
                       dataType: 'JSON',
                       type: 'POST',
                       success: function (data) {
                           $(".payment-cash-deposit").text(data.code.paying_deposit + "元");
                           $(".payment-service").text(data.code.paying_apply + "元");
                           $(".payment-voucher .payment-store-ccharges").text(data.code.paying_amount + " 元");
                       }
                   })
               }
           };


           //表单验证
           form.verify({
               province_id: function (value, item) {
                   if (value == '') {
                       return '省份不能为空';
                   }
               },
               city_id: function (value, item) {
                   if (value == '') {
                       return '城市不能为空';
                   }
               },
               district_id: function (value, item) {
                   if (value == '') {
                       return '区/县不能为空';
                   }
               },
               address: function (value) {
                   if (value == '') {
                       return '请输入详细地址';
                   }
               },
               telphone: function (value) {
                   var mobile = /^1[3|4|5|7|8]\d{9}$/;
                   var flag = mobile.test(value);
                   if (!flag) {
                       return '请输入正确的手机号';
                   }
               },
               card: function (value) {
                   var reg = /(^\d{15}$)|(^\d{17}(\d|[Xx])$)/;
                   if (!reg.test(value)) {
                       return '请输入正确的身份证号';
                   }
               }
           });
       });
    });

    $("body").on("click", ".error-reason", function(){
        layer.open({
            type: 0,
            content: '{$shop_apply_info["apply_message"]}'
        });
    });




    /* 图片上传 */
    $("[data-upload]").each(function () {

        var id = $(this).attr("data-id");
        var name = $(this).attr("data-name");

        layui.use("upload", function () {
            upload = layui.upload;

            upload.render({
                elem: "#" + id,
                url: ns.url("shop/upload/image"),
                done: function (res) {

                    if (res.code >= 0) {
                        $("input[name=" + name + " ]").val(res.data.pic_path);
                        $("#" + id).html("<img src=" + ns.img(res.data.pic_path) + " >");
                    }
                    return layer.msg(res.message);
                }
            });
        });
    });
</script>
{/block}